<template>
	<div style="padding:20px;">
		<el-row :gutter="20" id="app">
			<el-form ref="form" label-width="120px" style="padding:20px;">
				<el-col :span="12">
					<el-form-item label="A类到店次数">
						<el-input v-model="cate.A_arrive" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="B类到店次数">
						<el-input v-model="cate.B_arrive" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="C类到店次数">
						<el-input v-model="cate.C_arrive" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="D类到店次数">
						<el-input v-model="cate.D_arrive" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="E类到店次数">
						<el-input v-model="cate.E_arrive" size="mini"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="A类消费金额(元)">
						<el-input v-model="cate.A_money" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="B类消费金额(元)">
						<el-input v-model="cate.B_money" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="C类消费金额(元)">
						<el-input v-model="cate.C_money" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="D类消费金额(元)">
						<el-input v-model="cate.D_money" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="E类消费金额(元)">
						<el-input v-model="cate.E_money" size="mini"></el-input>
					</el-form-item>
				</el-col>
			</el-form>
		</el-row>
		<el-row>
			<el-col :span="12">
				<el-button @click.native="close" style="width:90%;display:block;">取消</el-button>
			</el-col>
			<el-col :span="12">
				<el-button type="success" @click.native="callSubmit" style="width:90%;display:block;" :loading="loading">确定</el-button>
			</el-col>
		</el-row>
	</div>
</template>
<script>
import C from '@/common/common.js'
export default {
  name: 'guestcategoryEdit',
  data () {
    return {
      cate: {},
      loading: false
    }
  },
  mounted () {
    this.cate = C.getDatas()
  },
  methods: {
    async callSubmit (index) {
      for (let i in this.cate) {
        if (!/^\d+$/.test(this.cate[i])) {
          C.error('请输入数字')
          return false
        }
      }
      this.loading = true
      let res = await C.ajax('/organization/category/setguestcategory', { data: JSON.stringify(this.cate) }, 'post')
      if (res) {
        if (res.errno === 0) {
          this.loading = false
          this.$notify({
            title: '成功',
            message: res.data,
            type: 'success'
          })
          C.closeBrowserWindow(res)
        } else {
          this.loading = false
          this.$notify.error({
            title: '错误',
            message: res.errmsg
          })
        }
      }
    },
    close () {
      C.closewin()
    }
  }
}
</script>